@ECHO OFF

IF NOT EXIST %~dp0settings.proj GOTO msbuild_not_configured

IF "%1" == "" SET FrameworkVersion=v4.0

IF "%1" == "NET40" (SET FrameworkVersion=v4.0)
IF "%1" == "NET40" (SET BuildConfigKey=NET40)

IF "%1" == "NET40CP" (SET FrameworkVersion=v4.0)
IF "%1" == "NET40CP" (SET BuildConfigKey=NET40CP)

IF "%1" == "NET35" (SET FrameworkVersion=v3.5)
IF "%1" == "NET35" (SET BuildConfigKey=NET35)

IF "%1" == "MONO26" (SET FrameworkVersion=v3.5)
IF "%1" == "MONO26" (SET BuildConfigKey=MONO26)


IF "%2" == "" (SET BuildTarget=FullBuild) ELSE (SET BuildTarget=%2)


IF "%3" == "" (SET BuildConfiguration=Release) ELSE (SET BuildConfiguration=%3)


echo Framework version is: %FrameworkVersion%
echo Build Target is: %BuildTarget%
echo Building configuration: %BuildConfiguration%


SET __MSBUILD_EXE__=%windir%\microsoft.net\framework\v4.0.30319\msbuild.exe

IF "%BuildTarget%" == "ClickToBuild" (SET Verbosity=minimal) ElSE (SET Verbosity=normal)

@echo on
%__MSBUILD_EXE__% /v:%Verbosity% /m "%~dp0build.proj" /property:BuildConfigKey=%BuildConfigKey% /p:TargetFrameworkVersion=%FrameworkVersion% /ToolsVersion:4.0  /property:Configuration=%BuildConfiguration% /t:%BuildTarget%
@echo off

IF %ERRORLEVEL% NEQ 0 GOTO err
EXIT /B 0

:err
EXIT /B 1

:msbuild_not_configured
echo This project is not configured to be built with MSBuild.
echo Please use the NAnt script in the root folder of this project.